package cn.mxz.utils;

import java.util.Date;
import java.util.Random;

public class OrderItemIdUtil {
	private static Long randomNumber;
	private static Long curIndex = Long.valueOf(0L);

	public OrderItemIdUtil() {
	}

	public synchronized static Long getId() throws Exception {
		Long index = null;
		// 从0到999 curIndex*100 curIndex 100-99900
		index = (curIndex = curIndex.longValue() + 1L).longValue() % 1000L;
		if (curIndex.longValue() >= 1000L) {
			curIndex = 0L;
		}
		// 随机数 1-10
		randomNumber = Long.valueOf(new Random().nextInt(100));
		return (new Date()).getTime() * 100000L + index.longValue() * 100L
				+ randomNumber.longValue();
	}

}
